<?php use_helper('date'); ?>

<div class="profil">
    <div class="cocotiers">
        <div class="plaque">
            <div class="plaque-left"></div>
            <div class="plaque-repeat">
                <?php if($sf_user->is($sf_guard_user)): ?>
                    C'est votre profil !
                <?php else: ?>
                    Profil de <?php echo $sf_guard_user->getPseudo() ?> 
                <?php endif; ?>
            </div>
            <div class="plaque-right"></div>
        </div>
        <div class="info-bubble">
            Je veux <span data-bind="text: describeTV">...</span>
        </div>
        <div class="up-row">
            <div class="left-col">
            </div>
            <div class="right-col">
                <div class="avatar-bubble avatar-bubble-black-bg">
                    <div class="avatar" style="background-image: url('<?php echo $sf_guard_user->getAvatar() ?>')"></div>
                    <div class="name daniel-font">
                        <?php echo link_to($sf_guard_user->getPseudo(), "show_player", $sf_guard_user); ?>
                         <div style="margin: 0 auto; margin-top: 1px;"title="<?php echo $sf_guard_user->isOnline() ? "En ligne" : "Hors ligne"?>" class="icon <?php echo $sf_guard_user->isOnline() ? "is-online" : "is-offline"?>"></div>
                    </div>
                </div>
                <br/><br/>
            </div>
        </div>
        
        <div class="tv-icons">
             <div data-bind="event: {mouseover: function(){ describeTV('bientôt les trophées !') }, mouseout: function(){describeTV('...')}}" class="tv-icon trophy"><a href="#"></a></div>
            <?php if($sf_user->is($sf_guard_user)): ?>
             <div data-bind="event: {mouseover: function(){ describeTV('changer des réglages !') }, mouseout: function(){describeTV('...')}}" class="tv-icon settings"><a href="<?php echo url_for("edit_player", $sf_guard_user)?>"></a></div>
             <div data-bind="event: {mouseover: function(){ describeTV('consulter mes messages privés !')}, mouseout: function(){describeTV('...')}}"class="tv-icon pm-box"><a href="<?php echo url_for("pm_box")?>"></a></div>
             <div data-bind="event: {mouseover: function(){ describeTV('créer un nouveau personnage !')}, mouseout: function(){describeTV('...')}}" class="tv-icon new-character"><a href="<?php echo url_for("create_character")?>"></a></div>
            <?php endif; ?>
        </div>
       
    </div>
    <div class="grass"></div>
    <div class="profil-cadre">
        <h3 class="sonic-title-font">inscrit depuis le</h3><div class="info"><?php echo format_date($sf_guard_user->getCreatedAt(), "p") ?> à <?php echo format_date($sf_guard_user->getCreatedAt(), "H:mm") ?></div>
        <div class="clear"></div>
        <h3 class="sonic-title-font">derniere activite le</h3><div class="info"><?php echo format_date($sf_guard_user->getPresence(), "p") ?> à <?php echo format_date($sf_guard_user->getPresence(), "H:mm") ?></div>
        <div class="clear"></div>
        <h3 class="sonic-title-font">rings</h3><div class="info"><?php echo $sf_guard_user->getMoney() ?> <?php echo $sf_user->isAuthenticated() ? '(<b>'.link_to("Donner ?", "prepare_money").'</b>)': NULL ?></div>
    </div>
    <div class="grass"></div>
    <div class="profil-cadre">
        
        <?php if($sf_guard_user->getHideEmail() == false || $sf_user->is($sf_guard_user) || $sf_user->hasPermission("see_hidden_email")): ?>
        <h3 class="sonic-title-font">adresse email</h3><div class="info"><?php echo $sf_guard_user->getEmailAddress() ?></div>
        <?php endif; ?>
        <div class="clear"></div>
        <h3 class="sonic-title-font">citation</h3><div class="info"><?php echo $sf_guard_user->getQuote() ?></div><br/>
        <div class="clear"></div>
        <h3 class="sonic-title-font">signature </h3><div class="info"><?php echo $sf_guard_user->getParsedSignature(ESC_RAW) ?></div>
    </div>
<?php if($sf_guard_user->hasCharacters()): ?>
   <div class="grass"></div>
    <div class="characters">
         
        <h3>Personnages de <?php echo $sf_guard_user->getPseudo() ?></h3>
        <div class="character_info">
            <div class="character_icon">
                <div class="micro-avatar-bubble">
                    <div class="avatar" data-bind="style: { backgroundImage: 'url('+characterAvatar+')' }" ></div>
                </div>
            </div>
            <div class="character_sum">
                <a class="bold" data-bind="attr: {href: characterURL }" href="#">
                        <span data-bind="text: characterPseudo">
                         </span>
                </a><br/>
                <span class="bold" data-bind="text: characterIsActualCharacter"></span><br/>
                <span class="bold" data-bind="text: characterRace"></span><br/>
                <span class="bold" data-bind="text: characterAge"></span><br/>
                <span class="bold" data-bind="text: characterAlignement"></span><br/><br/><br/>
                <?php if($sf_user->is($sf_guard_user)): ?>
                <a class="btn" data-bind="attr: { href: characterSwitchURL }">Choisir</a>
                <a class="btn primary" data-bind="attr: { href: characterURL }">Fiche</a>
                <?php endif; ?>
            </div>
        </div>
        <div class="characters-bubble-list">
            <h4>Reserve</h4>
            <?php $i = 0;?>
            <?php foreach($sf_guard_user->getKTDCharacters() as $character):?>
            <acronym title="<?php echo $character->getPseudo() ?>">
            <span style="cursor: pointer;"  data-bind="click: function(){ new focusOnCharacter(<?php echo $character->getId()?>); }">
                <div class="micro-avatar-bubble micro-bubble-bg-<?php echo $character->getFiche()->getAlignement()?>" style="float:left; margin: 2px;">
                    <div class="avatar" style="background-image: url('<?php echo $character->getAvatar(); ?>')"></div>
                </div>
            </span>
            </acronym>
            <?php $i++ ?>
            <?php endforeach;?>
        </div>
    </div>
</div>
<?php if($sf_user->is($sf_guard_user)): ?>
<script type="text/javascript">
    <?php foreach($sf_guard_user->getKTDCharacters() as $character): ?>
        KTDPlayer.addCharacter(
            KTDCharacter.convertArrayToModelView(
                    <?php echo KillTheDragon::convertToJSArray(array(
                                                                    "characterId"           => $character->getId(),
                                                                    "characterPseudo"       => $character->getPseudo(ESC_JS_NO_ENTITIES),
                                                                    "characterAvatar"       => $character->getAvatar(),
                                                                    "characterAge"          => $character->getFiche()->getAge() != NULL         ? $character->getFiche()->getAge()          : "Âge inconnu",
                                                                    "characterAlignement"   => $character->getFiche()->getAlignement() != NULL  ? $character->getFiche()->getAlignement()   : 'Alignement inconnu',
                                                                    "characterRace"         => $character->getFiche()->getRace() != NULL        ? $character->getFiche()->getRace()         : "Race indéterminée",
                                                                    "characterURL"          => url_for("show_fiche", $character),
                                                                    "characterSwitchURL"    => url_for("ajax_switch_player_character", array("character_id" => $character->getId())),
                                                                    "characterIsActualCharacter" => $sf_guard_user->getActualCharacter()->getId() == $character->getId() ? "Personnage selectionné" : ""
                                                                            )
                                                                    )
                            ?>
                                                  )
                              );
    <?php endforeach; ?>
</script>
<?php endif; ?>
<?php if(!$sf_user->is($sf_guard_user)): ?>
<script type="text/javascript">
    <?php foreach($sf_guard_user->getKTDCharacters() as $character): ?>
        KTDPlayer.addCharacter(
            KTDCharacter.convertArrayToModelView(
                    <?php echo KillTheDragon::convertToJSArray(array(
                                                                    "characterId"           => $character->getId(),
                                                                    "characterPseudo"       => $character->getPseudo(ESC_JS_NO_ENTITIES),
                                                                    "characterAvatar"       => $character->getAvatar(),
                                                                    "characterAge"          => $character->getFiche()->getAge() != NULL         ? $character->getFiche()->getAge()          : "Âge inconnu",
                                                                    "characterAlignement"   => $character->getFiche()->getAlignement() != NULL  ? $character->getFiche()->getAlignement()   : 'Alignement inconnu',
                                                                    "characterRace"         => $character->getFiche()->getRace() != NULL        ? $character->getFiche()->getRace()         : "Race indéterminée",
                                                                    "characterURL"          => url_for("show_fiche", $character),
                                                                    "characterIsActualCharacter" => ''
                                                                )
                                                                    )
                            ?>
                                                  )
                              );
    <?php endforeach; ?>
</script>
<?php endif; ?>
<script type="text/javascript">

    KTDPlayer.setActualCharacter(<?php echo $sf_guard_user->hasActualCharacter() ? $sf_guard_user->getActualCharacter()->getId() : $sf_guard_user->getRandomCharacter()->getId() ?>);
    ko.applyBindings(KTDPlayer.actualCharacter);
    
</script>
<?php else: ?>
<script type="text/javascript">
    var describeTVViewModel = function(){
    describeTV = ko.observable("...");
}
    ko.applyBindings(new describeTVViewModel());
</script>
<?php endif; ?>

